// 这是两个进程需要看到的公共数据
#pragma once

#include <iostream>
#include <string>

using namespace std;

const string gpipeFile = "./fifo";
const mode_t gmode = 0600;
const int gdefaultfd = -1;
const int gsize = 1024;
const int gForRead = O_RDONLY;
const int gForWrite = O_WRONLY;

int OpenPipe(int flag)
{
    int fd = ::open(gpipeFile.c_str(), flag); 
    if (fd < 0)                           
        cerr << "open failed" << endl;
    return fd;
}

void ClosePipeHelper(int fd)
{
    if(fd >= 0)  // 有才关闭
        ::close(fd);
}